<template>
	<mescroll-uni :height="height + 'px'" ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback" :up="upOption">
		<block v-for="(item, index) in groupSessionList"  :key="item.notice_id"><chat-session-item ref="chatSessionItem" @handle="toChatPage" :item="item" :index="index" type="groupChat"></chat-session-item></block>
	</mescroll-uni>
</template>

<script>
import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins.js';
import chatSessionItem from '@/components/chat/chat-session-item.vue';
import { mapState, mapActions } from 'vuex';
import { getGroupSessionList } from '@/store/dispatches.js';
export default {
	mixins: [MescrollMixin], // 使用mixin
	components: { chatSessionItem },
	props: {
		height: {
			default: null,
			type: [String, Number]
		}
	},
	data() {
		return {
			upOption: {
				page: { num: 0, size: 200 }
			},
			groupList: []
		};
	},
	computed: {
		...mapState({
			groupSessionList: state => state.iMessage.groupSessionList
		})
	},
	methods: {
		getGroupMessage() {
			if (this.mescroll) {
				this.mescroll.resetUpScroll(false);
			}
		},
		upCallback(mescroll) {
			getGroupSessionList({ num: mescroll.num, size: mescroll.size }).then(res => {
				this.mescroll.endBySize(res.data.data.length, res.data.total);
			});
		},
		toChatPage(data) {
			this.$emit('handle', data);
		}
	}
};
</script>

<style></style>
